


qui do "${code}/Data Preparation/dataprep"
gl out "${output}/forPaper/FigS2"

cap program drop coefsv
do "${code}/0.Programs/coefsv.do"

gl grset graphregion(color(white)) ylabel(, angle(0)) plotregion(margin(sides))

tempfile main
save `main' 
append using "${output}/clean/stringency_cases_ctrydate.dta"
replace ctrytext = lower(country) if mi(ctrytext)

graph drop _all
qui foreach c in kenyage rwanda nigeria bangladesh sierraleone colombia nepal kenyaipush kenyaklps drc  { //    uganda 
noi di "`c'"
preserve
keep if ctrytext == "`c'" | regexm("`c'", ctrytext)
	loc i = -1
	foreach y in  ___depression_nw     {  
		loc ++ i
		areg `y' ib1.month, absorb(pid) vce(cluster hhid)
		coefsv `y' month
		cap drop *_`y' `y'_lo `y'_hi `y'1
		replace r1 = r1 + 6*`i'
		sum b1
		foreach v in b1 b_hi b_lo {
		replace `v' = (`v' - `r(min)')/(`r(max)' - `r(min)')
		}
		replace b_hi = 1.1 if b_hi > 1.3
		replace b_lo = -0.1 if b_lo < -0.3
		ren (r1 b1 b_lo b_hi) (Round_`y' `y'1 `y'_lo `y'_hi) 
					loc col gs0 
				if `i' == 1   loc col gs6 
				if `i' == 2   loc col gs10 
		loc cis`y' rcap `y'_lo `y'_hi Round_`y' 
		loc plot`i' (scatter `y'1 Round_`y', color(`col') mlwidth(0)) (`cis`y'' , lcolor(`col') msize(vtiny))
	}
	
	if "`c'" == "kenyage" loc cname KEN2
	if "`c'" == "rwanda" loc cname RWA
	if "`c'" == "nigeria" loc cname NGA
	if "`c'" == "bangladesh" loc cname BGD
	if "`c'" == "sierraleone" loc cname SLE
	if "`c'" == "colombia" loc cname COL
	if "`c'" == "nepal" loc cname NPL
	if "`c'" == "kenyaipush" loc cname KEN3
	if "`c'" == "kenyaklps" loc cname KEN1
	if "`c'" == "drc" loc cname DRC
	
	
	gl covid = mdy(3,24,2020)
	sum date
	gl start = r(min)
	if "`c'" == "kenyage" gl start =  mdy(3,15,2015)
	gl end = r(max)
	gl xformat2 xlabel(${start}(61)${end}, angle(45) format(%tdmy) )
	if "`c'" == "colombia" gl xformat2 xlabel(${start}(121.67)${end}, angle(45) format(%tdmy) )
	if "`c'" == "drc" gl xformat2 xlabel(${start}(121.67)${end}, angle(45) format(%tdmy) )
	if "`c'" == "kenyaklps" gl xformat2 xlabel(${start}(121.67)${end}, angle(45) format(%tdmy) )
	if "`c'" == "kenyage" gl xformat2 xlabel(${start}(182.5)${end}, angle(45) format(%tdmy) )
	if "`c'" == "rwanda" gl xformat2 xlabel(${start}(121.67)${end}, angle(45) format(%tdmy) )
	gl xformat2 ${xformat2} ylabel(, format(%9.0g) )
	gl grset graphregion(color(white)) ylabel(, angle(0)) plotregion(margin(sides))
	tw (line rel_case date, sort col(%50)) (line strind date, sort lpattern("-")) `plot0' , $xformat2 $grset ///
		legend(order(3 "Depression"  1 "Relative Cases" 2 "Stringency" ))  name(`c') ///
		title(`cname') xline($covid, lpattern(dash))
graph export "${out}/strind_case_mh_`c'_nw.png", replace
	
restore
}

grc1leg bangladesh colombia drc kenyage kenyaipush kenyaklps nepal nigeria rwanda sierraleone   , /// 
	cols(4) graphregion(color(white) margin(zero)) plotregion(margin(sides)) xsize(10) ysize(7)
graph export "${out}/strind_case_mh_nw.pdf", replace
